<template>
  <div class="step-two">
    <h3 class="requireh3">产品信息</h3>
    <!-- 产品信息 -->
    <m-form
      :hide-required-asterisk="true"
      class="form-product"
      label-width="92px"
      label-position="right"
    >
      <m-form-item label="产品名称：" class="product-item product-name no-icon">
        <div class="content">{{ mydata.goods_info }}</div>
      </m-form-item>
      <m-form-item label="产品类型：" class="product-item product-type no-icon">
        <div class="content">
          {{ mydata.goods_type == "1" ? "包装材料" : "配套服务" }}
        </div>
      </m-form-item>
      <m-form-item label="产品分类：" class="product-item product-sort no-icon">
        <div class="content" v-if="type != 'edit'">
          {{ mydata.goods_class_1_txt }}{{ mydata.goods_class_2_txt ? `>${mydata.goods_class_2_txt}` : '' }}
        </div>
        <div class="content" v-else>
          {{ mydata.class1.cate_name }}>{{ mydata.class2.cate_name }}
        </div>
      </m-form-item>
      <m-form-item
        label="产品数量："
        class="product-item product-quantity no-icon"
      >
        <div class="content">
          {{ mydata.goods_num }} {{ mydata.goods_unit_txt }}
        </div>
      </m-form-item>
      <m-form-item
        label="贸易条件："
        class="product-item product-trade-condition no-icon"
      >
        <div class="content">{{ mydata.goods_condition }}</div>
      </m-form-item>
      <m-form-item
        label="期望单价："
        class="product-item product-expected-price no-icon"
      >
        <div class="content">
          {{ mydata.goods_price }} {{ mydata.currency == 0 ? "人民币" : "元" }}
        </div>
      </m-form-item>
      <m-form-item label="产品图片：" class="product-item product-pics no-icon">
        <div class="pics-box" v-if="mydata.proPic">
          <div
            class="pic-item"
            v-for="(item, index) in mydata.proPic"
            :key="index"
          >
            <img :src="item" alt="" />
          </div>
        </div>
        <div class="content" v-else>
          <div class="annex-name">暂无</div>
        </div>
      </m-form-item>
      <m-form-item
        label="产品附件："
        class="product-item product-annex no-icon"
      >
        <div class="content">
          <div class="annex-name" v-if="mydata.proFile">
            {{ mydata.proFile[0] }}
          </div>
          <div class="annex-name" v-else>暂无</div>
        </div>
      </m-form-item>
    </m-form>
    <div class="line" />
    <!-- 配送与支付 -->
    <h3 class="requireh3">配送与支付</h3>
    <m-form
      :hide-required-asterisk="true"
      class="form-delivery"
      label-width="92px"
      label-position="right"
    >
      <m-form-item
        label="运输方式："
        class="delivery-item delivery-way no-icon"
      >
        <div class="content">{{ mydata.transport_type_txt }}</div>
      </m-form-item>
      <m-form-item
        label="目的地："
        class="delivery-item delivery-destination no-icon"
      >
        <div class="content">{{ mydata.province }}{{ mydata.city }}</div>
      </m-form-item>
      <m-form-item
        label="详细地址："
        class="delivery-item delivery-address no-icon"
      >
        <div class="content">{{ mydata.address }}</div>
      </m-form-item>
      <m-form-item
        label="期望交期："
        class="delivery-item delivery-date no-icon"
      >
        <div class="content">{{ mydata.days }}天</div>
      </m-form-item>
      <m-form-item
        label="支付方式："
        class="delivery-item delivery-payment no-icon"
      >
        <div class="content">
          {{ mydata.pay_type == "0" ? "线上支付" : "线下支付" }}
        </div>
      </m-form-item>
      <m-form-item
        label="备注："
        class="delivery-item delivery-remarks no-icon"
      >
        <div class="content">
          {{ mydata.remarks }}
        </div>
      </m-form-item>
      <div class="line" />
      <!-- 发布规则 -->
      <h3 class="requireh3">发布规则</h3>
      <div class="rules">
        <div class="rules-options">
          <checkbox-group v-model="mydata.rulesCheckList">
            <checkbox
              class="checkbox-item"
              name="agree"
              shape="square"
              checked-color="#E48B2C"
            >
            </checkbox>
            我已阅读 , 理解并同意找包装网的
            <a href="javascript:;" @click.stop="centerDialogVisible = true"
              >发布需求</a
            >
            规则 。
          </checkbox-group>
        </div>
      </div>
    </m-form>
    <!-- 平台规则 -->
    <Dialog
      :title="rules.title"
      :visible.sync="centerDialogVisible"
      width="30%"
      class="plat-rules"
      center
    >
      <span v-html="rules.content"></span>
    </Dialog>
  </div>
</template>

<script>
import { Checkbox, CheckboxGroup } from "vant";
import MForm from "@/components/common/m-form/MForm";
import MFormItem from "@/components/common/m-form/MFormItem";
import { platformRules } from "@/request/api";
import { Dialog } from "element-ui";

export default {
  name: "Official2",
  props: {
    type: String,
    mydata: {
      type: Object
    }
  },
  components: { MFormItem, MForm, Checkbox, CheckboxGroup, Dialog },
  data() {
    return {
      rules: {},
      centerDialogVisible: false
    };
  },
  created() {
    if (!this.mydata.address) {
      this.$parent.active = 0;
      this.$router.push({ path: "/require/1" });
    }
    this.getRules();
  },
  methods: {
    getRules() {
      platformRules(20).then(res => {
        if (res.status === 200) {
          this.rules = res.data;
        }
      });
    }
  }
};
</script>

<style lang="scss" scoped>
@import "~@/assets/style/common.scss";

.plat-rules /deep/ .el-dialog__body {
  height: 350px;
  overflow-y: auto;
}

.step-two {
  .requireh3 {
    margin-bottom: 14px;
  }

  .line {
    height: 1px;
    background: #e9e9e9;
    margin: 58px 0;
  }

  .product-item,
  .delivery-item {
    .content {
      height: 100%;
      display: flex;
      align-items: flex-end;
      font-size: 16px;
    }

    /deep/ .m-form-item__label {
      min-width: 93px;
      padding-left: 0;
      display: flex;
      align-items: flex-start;
    }
  }

  .form-product {
    .product-pics {
      .pics-box {
        .pic-item {
          display: inline-block;

          &:not(:last-of-type) {
            margin-right: 10px;
          }

          img {
            width: 140px;
            height: 140px;
          }
        }
      }
    }

    .product-annex {
      .content {
        display: flex;
        align-items: center;

        img {
          width: 38px;
          height: 38px;
        }

        .annex-name {
          margin-left: 10px;
          display: inline-block;
          font-size: 13px;
          color: #bbbbbb;
        }
      }
    }
  }

  .suppliers {
    .suppliers-list {
      margin-top: 38px;
      display: flex;
      flex-wrap: wrap;
      margin-right: -12px;

      .supplier-pic {
        width: 200px;
        margin-right: 12px;
        margin-bottom: 40px;
        position: relative;

        .pic-box {
          height: 156px;
        }

        .supplier-name {
          margin-top: 18px;
          text-align: center;
          z-index: 100;
        }

        .mask {
          display: none;
          position: absolute;
          top: 0;
          left: 0;
          width: 198px;
          height: 196px;
          background: rgba(0, 0, 0, 0.4);
          z-index: 99;
        }

        &:hover {
          .supplier-name {
            color: #fff;
            margin-top: -8px;
            transition: all 0.3s;
            position: relative;
          }

          .mask {
            display: block;
          }
        }
      }
    }

    .suppliers-options {
      margin-top: 38px;

      .checkbox-item {
        margin-bottom: 20px;
        font-size: 14px;

        &:nth-of-type(3) {
          /deep/ .van-checkbox__label {
            display: flex;
            align-items: center;

            div {
              height: 17px;
            }

            img {
              width: 15px;
              height: 15px;
              margin: 0 5px;
            }
          }
        }
      }
    }
  }

  .rules {
    margin-top: 38px;

    .rules-options {
      .van-checkbox-group {
        display: flex;
        justify-content: flex-start;
        align-items: center;
      }
      .checkbox-item {
        // margin-bottom: 20px;
        margin-right: 10px;
        font-size: 14px;
      }
      a {
        color: $theme-color-1;
        font-weight: bold;
      }
    }
  }
}
</style>
